<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="cms no-js ie ie6 ie-old"> <![endif]-->
<!--[if IE 7 ]>    <html class="cms no-js ie ie7 ie-old"> <![endif]-->
<!--[if IE 8 ]>    <html class="cms no-js ie ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="cms no-js ie ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="cms no-js"> <!--<![endif]-->
  <head>
	<?php
		if ($sf_context->has("settings")){
			$settings=$sf_context->get("settings");
		}else{
			$settings=Settings::getInstance();
		}
		/* @var $settings Setting */

	    if ($sf_context->has("templateSettings")){
			$templateSettings=$sf_context->get("templateSettings");
		}else{
			$templateSettings=TemplateSettings::getInstance();
		}

	  	$currentSection = null;
		if ($sf_context->has("section")){
			$currentSection = $sf_context->get("section");
		}
	?>
    <?php include_http_metas() ?>
    <?php include_metas() ?>
    <?php include_title() ?>
    <?php include_stylesheets() ?>
    <?php include_javascripts() ?>

	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<link rel="shortcut icon" href="<?= $settings["site.favicon"] ?>" />
	<title><?= $settings["site.page_title"] ?></title>
	<meta name="keywords" content="<?= $settings["site.metaKeywords"] ?>" />
	<meta name="description" content="<?= $settings["site.metaDescription"] ?>" />
	<meta name="author" content="<?= $settings["site.ownerName"] ?>" />

	<!-- CSS RESET -->
	<link rel="stylesheet" href="/css/reset.css" type="text/css" />

	<!-- CSS FOR BERTA (only for editing mode) -->
	<link rel="Stylesheet" href="/lib/jquery-ui/css/berta/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" href="/css/editor.css" type="text/css" />
	<link rel="stylesheet" href="/css/rte_ui.css" type="text/css" />
	<!-- CSS FOR PLUGINS (only for editing mode) -->
	<link rel="stylesheet" href="/lib/css/colorpicker.css" type="text/css" />

	<!-- CSS for template -->
	<link rel="stylesheet" href="<?= url_for("settings_css") ?>" type="text/css" />
	<link rel="stylesheet" href="<?= url_for("template_settings_css") ?>" type="text/css" />

  </head>


  <body>
    <?= $sf_content ?>

  


    <!-- JQUERY and default plugins -->
	<script src="/lib/jquery/jquery-1.5.min.js" type="text/javascript"></script>
	<!--<script src="/lib/jquery/jquery-1.4.2.js" type="text/javascript"></script>-->
	<script src="/lib/plugins/jquery.cycle.min.js"></script>


	<!-- SETTINGS -->
	<script>
	if(!window.Berta) window.Berta = {};

	/**
	 * Define the base suffixes for URIs
	 */
	Berta.URLBase =
	{
		'REST': '/admin',		// Prefix for REST requests
		'files': ''				// Prefix for real file requests
	}

	/**
	 * Define some of the routes
	 * TO DO: add more routes
	 */
	Berta.Routes =
	{
		'get:settings': { url: '/settings.json' },
		'get:template-settings': { url: '/template-settings/$id.json', variables: [ 'id' ] },
		'get:section-settings': { url: '/section-settings/$id.json', variables: [ 'id' ] },

		'put:settings': { url: '/settings.json', container: 'setting' },
		'put:template-settings': { url: '/template-settings/$id.json', variables: [ 'id' ], container: 'setting' },
		'put:section-settings': { url: '/section-settings/$id.json', variables: [ 'id' ], container: 'setting' },

		'post:entries': { url: '/entries.json', container: 'entry' },	// Create new entry
		'put:entry': { url: '/entries/$id.json', variables: [ 'id' ], container: 'entry' },
		'delete:entry': { url: '/entries/$id.json', variables: [ 'id' ], container: 'entry' },
		'put:entry-demote': { url: '/entries/$id/demote', variables: [ 'id' ], container: 'entry' },
		'put:entry-promote': { url: '/entries/$id/promote', variables: [ 'id' ], container: 'entry' },

		'get:images': { url: '/images.json', container: 'entry_image' },
		'post:images': { url: '/images.json', container: 'entry_image' },
		'put:image': { url: '/images/$id.json', variables: [ 'id' ], container: 'entry_image' },
		'del:image': { url: '/images/$id.json', variables: [ 'id' ] },


		'get:sections': { url: '/sections.json' },	// Get all sections in JSON
		'post:sections': { url: '/sections.json', container: 'section' },	// Create new section
		'put:section': { url: '/sections/$id.json', variables: [ 'id' ], container: 'section' },
		'delete:section': { url: '/sections/$id.json', variables: [ 'id' ], container: 'section' },
		'put:section-demote': { url: '/sections/$id/demote', variables: [ 'id' ], container: 'section' },
		'put:section-promote': { url: '/sections/$id/demote', variables: [ 'id' ], container: 'section' },

		'get:snippet-menu': { url: '/home', data: { 'snippetName': 'menu'} },
		'get:snippet-entry-gallery': { url: '/entries/$id', variables: [ 'id' ], data: { 'snippetName': 'gallery'} },
		'get:snippet-entry-listed': { url: '/entries/$id', variables: [ 'id' ], data: { 'snippetName': 'listed'} }



	};

	/**
	 * Set some settings
	 */
	Berta.Options =
	{
		// Id of the current section
		section_id: <?= $currentSection ? $currentSection->id : 'null'; ?>,

		// Templte id for the current section (either the global template, or section template, if set explicitly)
		template_id: <?= $settings["template.template_id"] /* Update to section template_id later */ ?>,

		// Global template, set in global settings
		global_template_id: <?= $settings["template.template_id"] ?>
	}


	</script>



	<!-- JS FOR BERTA (only for editing mode) -->
	<script src="/lib/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"></script>
	<!-- TODO: get rid of JQUERY-UI package -->

	<!-- Raphael SVG engine for grid and guides (only for editing mode) -->
	<script src="/lib/raphael-min.js"></script>

	<!-- 3rd party jquery plugins (only for editing mode) -->
	<script src="/lib/plugins/jquery.debug.js"></script>
	<script src="/lib/plugins/jquery.css.js"></script>
	<script src="/lib/plugins/jquery.cookie.js"></script>
	<script src="/lib/plugins/jquery.colorpicker.js"></script>

	<!-- tinymce... TODO: compress and use lazy instantiation -->
	<script src="/lib/tiny_mce/jquery.tinymce.js"></script>
	<script src="/lib/tiny_mce/tiny_mce.js"></script>

	<!-- berta's jquery plugins (only for editing mode) -->
	<script src="/js/jquery-plugins/jquery.uniqid.js"></script>
	<script src="/js/jquery-plugins/jquery.berta_extensions.js"></script>
	<script src="/js/jquery-plugins/jquery.berta_editable.js"></script>

	<!-- berta's basic classes (only for editing mode) -->
	<script src="/lib/essentials/class.js"></script>
	<script src="/js/class.berta.js"></script>
	<script src="/js/class.berta.route.js"></script>
	<script src="/js/class.berta.storage.js"></script>
	<script src="/js/class.berta.server.js"></script>
	<script src="/js/class.berta.server.upload.js"></script>
	<script src="/js/class.berta.settings.js"></script>
	<script src="/js/class.berta.grid.js"></script>

	<!-- berta's panel scripts (only for editing mode) -->
	<script src="/js/class.berta.panel.js"></script>
	<script src="/js/panes/class.pane.js"></script>
	<script src="/js/panes/class.pane.contextual.js"></script>
	<script src="/js/panes/class.pane.sections.js"></script>
	<script src="/js/panes/class.pane.layout.js"></script>
	<script src="/js/panes/class.pane.settings.js"></script>
	<script src="/js/panes/class.pane.grid.js"></script>

	<!-- berta's settings renderer (only for editing mode) -->
	<script src="/js/settingsrenderer/class.settingsrenderer.js"></script>
	<script src="/js/settingsrenderer/renderer.basics.js"></script>
	<script src="/js/settingsrenderer/renderer.gallery.js"></script>

	<!-- berta's editors (only for editing mode) -->
	<script src="/js/editors/class.editor.js"></script>
	<script src="/js/class.berta.editormanager.js"></script>
	<script src="/js/editors/class.editor.textline.js"></script>
	<script src="/js/editors/class.editor.number.js"></script>
	<script src="/js/editors/class.editor.rte.js"></script>
	<script src="/js/editors/class.editor.onoff.js"></script>
	<script src="/js/editors/class.editor.select.js"></script>
	<script src="/js/editors/class.editor.color.js"></script>
	<script src="/js/editors/class.editor.file.js"></script>
	<script src="/js/editors/class.editor.draggable.js"></script>

	<!-- berta's main controller and main init script (only for editing mode) -->
	<script src="/js/class.berta.articles.js"></script>
	<script src="/js/class.berta.controller.js"></script>
	<script src="/js/Berta_Test.js"></script>


	<!-- JS assets for template -->
	<script src="/templates/_shared/class.bertatemplate.slideshowgallery.js"></script>

	<!-- setting JS -->
	<!--<script src="<?= url_for("settings_js") ?>"></script>-->
    <script src="<?= url_for("template_settings_js") ?>"></script>


  </body>
</html>
